/*
 * @Author: wujian wujian@citycloud.com.cn
 * @Date: 2019-10-16 21:04:42
 * @LastEditors: wujian wujian@citycloud.com.cn
 * @LastEditTime: 2023-04-04 17:06:41
 * @FilePath: \es6\src\promise\promise.js
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 */
// function* NinjaGenrator() {
//   try {
//     yield "Hattori";
//     fail(`The expected exception didn't occur`);
//   } catch (e) {
//     console.log(e);
//   }
// }
// const ninjaIterator = NinjaGenrator();
// const result1 = ninjaIterator.next();
// console.log(result1.value);
// ninjaIterator.throw(`Catch this!`);

// const ninjaPromise = new Promise((resolve, reject) => resolve("Hattori1"));
// ninjaPromise.then(
//   (ninja) => {
//     console.log(ninja);
//   },
//   (err) => console.log(err)
// );

async function test() {
  let a = await text1().catch((err) => err);
  let b = await text2();
  console.log(a, b);
  console.log(0);
}

function text1() {
  console.log(1);
  return Promise.reject("err");
}

function text2() {
  console.log(2);
  return new Promise((resolve, reject) => reject("Hattori1"));
}

// test();

async function fn() {
  try {
    //await text1();
    let a = await Promise.reject("error");
  } catch (error) {
    console.log(error);
  }
}

fn();
